package cn.t222.config.mq;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

@Configuration
public class RabbitConfig {
    public static final String QUEUE_ORDER_CANCEL = "queue_order_cancel";
    public static final String DELAYED_EXCHANGE2 = "delayed_exchange2";
    @Bean
    Queue queue() {
        return new Queue(QUEUE_ORDER_CANCEL);
    }
    @Bean
    CustomExchange delayExchange() {
        Map<String, Object> args = new HashMap<>();
        args.put("x-delayed-type", "direct");
        return new CustomExchange(DELAYED_EXCHANGE2,"x-delayed-message",true, false, args);
    }
    @Bean
    Binding bindingDelay() {
        return BindingBuilder.bind(queue()).to(delayExchange()).with(QUEUE_ORDER_CANCEL).noargs();
    }

}
